//
//  GYXWebViewController.swift
//  GYXWeibo
//
//  Created by Twisal on 2017/4/11.
//  Copyright © 2017年 Twisal. All rights reserved.
//

import UIKit


// MARK: - 自定义webView
class GYXWebViewController: GYXBaseViewController {

    
    /// url字符串
    var urlString: String? {
        didSet {
            guard let urlString = urlString,
                let url = URL(string: urlString)
            else {
                return
            }
            
            webView.loadRequest(URLRequest(url: url))
        }
    }
    
    /// 懒加载webView
    fileprivate lazy var webView = UIWebView(frame: UIScreen.main.bounds)
}


// MARK: - 页面布局
extension GYXWebViewController {
    override func setupTableView() {
        // 设置标题
        naviItem.title = "网页"
        // 添加webView到控制器中
        view.insertSubview(webView, belowSubview: naviBar)
        // 设置top缩进
        webView.scrollView.contentInset.top = naviBar.bounds.height
        // 隐藏指示条
        webView.scrollView.showsVerticalScrollIndicator = false
        // 设置背景
        webView.backgroundColor = UIColor.white
    }
}
